home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Herra / TIMWIN.ZIP / DCOINS.CMD < prev    next >
OS/2 REXX Batch file  |  1993-09-22  |  3KB  |  99 lines

  1. ;   TIM - DEMO                  1.12     DCOINS
  2. ;
  3. ; analysis of image 'muntsq' using distance transform
  4. ; expects: image 'muntsq' in 'a'
  5. ;
  6. ; The analysis is based on the fact, that the distance transform transforms
  7. ; a circular object to a cone, with a top consisting of exactly one pixel.
  8. ; This pixel's grey value represents its original size. The process is
  9. ; relatively insensitive to disturbances in shape due to touching objects.
  10. ; The position of the maximum can easily be found by producing the maximum
  11. ; of the distance transformed image. Pixels in both images having the same
  12. ; value represent the top (and the base).
  13. ;
  14. ;     -----    <--- maximum of cone
  15. ;    /  ^  \
  16. ;   /  / \  \
  17. ;         \-------- original cone
  18. ;
  19. #include timdefs.h
  20. parms
  21.   int windis
  22. endparms
  23. int num = 2
  24. int aant
  25. int distance
  26. int grv
  27. int top = 4
  28. int totaal = 0
  29. int nGulden = 0
  30. int nKwartje = 0
  31. int nDubbeltje = 0 
  32. int nStuiver = 0
  33.  
  34. *inilock         ;lock cursors (if necessary)
  35. dest a
  36. *windispl h (windis+WINLUT1)
  37. dest p
  38. perc a 7         ;remove noise
  39. save r           ;keep as original
  40. thre  8          ;keep coins
  41. dt               ;distance transform. Circular objs are transformed to cones.
  42. *windispl i windis
  43. dest q            ;
  44. max p 7          ;get maximum:  
  45. dest s            ;
  46. comp p == q      ;pixels                
  47. curlock q s 1    ;couple cursors to access neccesary data in q and r
  48. curlock r s 1    ;                    
  49. mark 1           ;reset mark-pointer
  50. aant = label
  51. cls
  52. scrs top 1
  53. print "   C O I N                Number            Amount"
  54. print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  55. ;scrs (top+2) 1
  56. print "100c piece (gulden): "
  57. ;scrs (top+3) 1
  58. print " 25c piece (kwartje): " 
  59. ;scrs (top+4) 1
  60. print " 10c piece (dubbeltje): " 
  61. ;scrs (top+5) 1
  62. print "  5c piece (stuiver): " 
  63. ;scrs (top+6) 1
  64. print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  65.  
  66.  
  67.  
  68. for num = 1 to aant step 1
  69.   mark num /     ;search next object starting from reached position
  70.     ;get grey value from corresponding position in dt-image
  71.   if (distance = bgm q) > 95  ;analysis is based on size ...
  72.      scrs (top+2) 1
  73.      print  @30 ++nGulden,   @45 (nGulden*100), @z
  74.      totaal += 100
  75.   elseif distance > 70
  76.      if (bgm r) < 40    ; ... and grey value
  77.        scrs (top+5) 1
  78.        print  @30 ++nStuiver,  @45 (nStuiver*5),  @z
  79.      totaal += 5
  80.      else
  81.        scrs (top+3) 1
  82.        print  @30 ++nKwartje,  @45 (nKwartje*25), @z
  83.      totaal += 25
  84.      endif
  85.   elseif distance > 50
  86.      scrs (top+4) 1
  87.      print  @30 ++nDubbeltje, @45 (nDubbeltje*10), @z
  88.      totaal += 10
  89.   endif
  90.   scrs (top+7) 1
  91.   print @20 "Total:" @45 totaal
  92. endfor
  93.  
  94. curlock r s 0
  95. curlock q s 0
  96. stop
  97.  
  98. 
  99.